/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');

// Schema 结构
var UsernameSchema = new mongoose.Schema({
    uid         :{type:Number,index: true},//uid
    username    : {type : String,index: true},//用户和名
    password    : {type : String},//密码
    payPassword    : {type : String},//支付密码
    email    : {type : String},//邮箱
    emailBind    : {type : String,default:'F'},//邮箱是否绑定
    createTime     : {type : String, default: new Date().getTime()+''},//注册时间
    age      : {type : String,default:1},//年龄
    sex      : {type : String,default:'男'},//性别
    phone      : {type : String},//手机
    address      : {type : String},//地址
    realname: {type : String}//实名
});

UsernameSchema.statics.findFn = function(obj, callback) {
    return this.model('Username').find(obj, callback);
};
UsernameSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Username').findOne(obj).sort(obj1).exec(callback);
};
UsernameSchema.statics.updateFn = function(obj,obj1,callback) {
    return this.model('Username').update(obj,obj1).exec(callback);
};

var UsernameModel = db.model('Username', UsernameSchema);

module.exports=UsernameModel;